package wei.xinya.pattern.creational.singleton;

/**
 * 懒汉：代码块加锁单例模式
 */
public class Lock2Singleton {
    private static Lock2Singleton singleton;

    private Lock2Singleton() {
    }

    public static Lock2Singleton getSingleton() {
        if (singleton == null) {
            synchronized (Lock2Singleton.class) {
                singleton = new Lock2Singleton();
            }
        }

        return singleton;
    }
}
